package com.yanqu.road.server.cmd.player;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.user.CrossUserNotifyMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;

/**
 * @author ：zfr
 * @date ：2021/8/18 15:19
 */
@Cmd(code = CrossProtocol.C_CROSS_UPDATE_USER_BASE_INFO, desc = "跨服更新玩家信息")
public class CrossUpdateUserBaseInfoCmd extends CrossCommand {
    private long userId;
    private UserBaseInfo userBaseInfo;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        PlayerProto.PlayerSimpleTempMsg msg = PlayerProto.PlayerSimpleTempMsg.parseFrom(packet.getBytes());
        userId = msg.getUserId();
        userBaseInfo = PlayerBasePb.parseBaseUserInfo(msg.getPlayerBaseData());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossUserNotifyMgr.notifyReload(userBaseInfo, userId);
    }

    @Override
    public void sendData() {

    }
}
